home *** CD-ROM | disk | FTP | other *** search
- Path: druid.borland.com!usenet
- From: pete@borland.com (Pete Becker)
- Newsgroups: comp.lang.c++
- Subject: Re: DESPERATE with Borland C++ 4.5 compiler
- Date: 1 Mar 1996 18:15:54 GMT
- Organization: Borland International
- Message-ID: <4h7esq$6v@druid.borland.com>
- References: <4h08er$op5@news.cs.tu-berlin.de>
- NNTP-Posting-Host: pbecker.borland.com
- Mime-Version: 1.0
- Content-Type: Text/Plain; charset=ISO-8859-1
- X-Newsreader: WinVN 0.99.5
-
- In article <4h08er$op5@news.cs.tu-berlin.de>, wolfro@cs.tu-berlin.de says...
- >
- >Ali Lattunen <Ali.Lattunen@vtt.fi> writes:
- >>
- >> Still the same problem:
- >>
- >> Linker recognizes only one instance of template class non-inline member
- >> functions. If I have two template class instancies of different user
- >> defined type as my class members, e.g.,
- >>
- >> class MyClass {
- >> ..
- >> TemplateClass<X> XMember;
- >> TemplateClass<Y> YMember;
- >> };
- >>
- >> member functions TemplateClass<Y>::XXX that are not inline are not
- >> recognized by the linker.
- >>
- >> If I declare them inline, the linker works fine even if the compiler
- >> warns that functions cannot be expanded inline due to while-statements
- >> inside the function body.
- >>
- >> How is this done right?
- >> How can I avoid using inline functions here?
- >>
- >> Does Borland have any online user information service?
- >>
- >
- >Well, I've had the same problem. As far as I understand this mess there is a
- bug
- >in the compiler. When you create a template class and then instantiate it the
- compiler
- >has to generate the code for the member functions. Certainly the code has to
- be placed
- >in some module. The "Smart Template" option lets the compiler select the
- module for the
- >code. Probably you can guess... this stupid thing doesn't generate the code
- at all ( the
- >inline functions run since no code needs to be generated - they are inline,
- aren't they ).
- >The only solution I have found is to compile one module with the -Jgd (
- Global Templates )
- >option and the others with the -Jgx ( External Templates ) option. A nice
- side effect is
- >that you cannot use precompiled headers if these options are specified in the
- makefile or
- >in the project. So you have to use #pragma's after the #include's and
- instantiate ALL of
- >your template classes in ONE module or cast all those #pragma's all over your
- source...
- >it's really a mess but it works.
- >By the way, there is one thing I don't understand. The first time I
- encountered this problem
- >I tried to compile some of the example files which deal with template and
- they didn't run
- >either. Now tell me, am I doing something wrong or don't these guys test
- their examples at all?
-
- Don't mess with the -Jg switches. They'll get you into trouble. The
- template model that every compiler today except cfront supports is that the
- compiler has to see the entire template definition at the point where it is
- used. That includes non-inline member functions. The easiest way to do this is
- to put everything in the header file.
-
-